/**
    ATClab - scriptable Air Traffic Control simulations.
    Copyright (C) 2010 openatclab@gmail.com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
**/

#ifndef __ATC_SKY_IMPL_HDR__
#define __ATC_SKY_IMPL_HDR__


#ifdef WIN32
	// identifier truncated in debug information
	#pragma warning(disable:4786)
#endif


#include "sky.h"
#include "aircraftparam.h"
#include "area_definition.h"


namespace atc{

	/*!
	 *
	 */
	typedef std::map< std::string, atc::AreaDefinition > AreaHash;

	/*!
	 * \struct atc::sky_error
	 */
	struct sky_error : public std::runtime_error{
		sky_error(const std::string& msg) : std::runtime_error(msg){}
	};


	/*!
	 * \class atc::SkyImpl atc_sky_impl.h
	 */
	class SkyImpl : public atc::Sky
	{
	public:

		SkyImpl();
		virtual ~SkyImpl();

	public: // Sky Interface [creational]

		void create_aircraft(
			const char *,
			const char * = ""
		);

		void set_aircraft_launch(const char *, unsigned int);

		void add_aircraft_pathdescriptor(
				const char *,
				double, double,
				double = DEFAULT, double = DEFAULT,
				double = DEFAULT, double = DEFAULT
			);

//		void add_aircraft_pathdescriptor(
//			const char *, 
//			double, double, double, double
//		);

		void set_aircraft_initialaltitude(const char *, double);
		void set_aircraft_initialvelocity(const char *, double);

		void set_aircraft_closedpath(
				const char *, bool = true
			);

		void create_weather( const char * );
		void add_weather_vertex( const char *, double , double );
		void add_weather_arc( const char *, double , double , double );
		void add_weather_ellipse( 
				const char *, double , double , double, double, double
			);
		void add_conflicts( const ConflictDeclarationMap & );

	public:

		const atc::AircraftParamMap& aircraft()const{ return _aircraft; }
		const atc::AreaHash& weather_systems() const { return _area_at; }
		ConflictDeclarationMap* conflicts() { return &_conflicts; }

	private:

		atc::AircraftParamMapIt findAircraft(const char *);
		void validate( const char * );

	private:

		atc::AircraftParamMap _aircraft;
		atc::AreaHash _area_at;
		atc::ConflictDeclarationMap _conflicts;

	};
}

#endif
